﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _006_007详解类型变量与与对象_1_垃圾回收机制
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }


        //新增队列 把变量制造在内存当中
        List<Window> winList;
        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            winList = new List<Window>();
            for (int i = 0; i < 15000; i++)
            {
                Window win = new Window();
                winList.Add(win);
            }
        }

        //清除队列中的数据  垃圾回收  C#垃圾收集器在合适时机也能自动回收
        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            winList.Clear();
        }
    }
}